﻿using SqlSugar;

namespace Zhp.Auth.Model
{
    public class OnlineUserModel
    {
        /// <summary>
        /// OnlineId+TokenType拼接
        /// </summary>
        public string CacheId => $"{OnlineId}_{TokenType}";
        /// <summary>
        /// 多用户登录时值为RefreshTokenId，单设备登录时值为UserId
        /// </summary>
        public long OnlineId { get; set; }
        /// <summary>
        /// jwt编号
        /// </summary>
        public long RefreshTokenId { get; set; }
        public long AccessTokenId { get; set; }
        public TokenTypeEnum TokenType { get; set; }
        public int CompanyCode { get; set; }
        public long UserId { get; set; }
        public string WorkDayId { get; set; }
        public string UserCode { get; set; }
        public string UserName { get; set; }
        public List<long> RoleIds { get; set; }

        public string ConnectionId { get; set; }

        public string RequestIp { get; set; }

        public string IpAddress { get; set; }
        public string OperatingSystem { get; set; }
        public string DeviceType { get; set; }
        public string BrowserName { get; set; }
        public string Version { get; set; }

        public DateTime LoginTime { get; set; }

        public DateTime CreateTime { get; set; }

        public DateTime AccessExpiresTime { get; set; }

        public DateTime RefreshExpiresTime { get; set; }
    }

    public class OnlineUserViewModel
    {
        /// <summary>
        /// OnlineId+TokenType拼接
        /// </summary>
        public string CacheId { get; set; }
        /// <summary>
        /// 多用户登录时值为RefreshTokenId，单设备登录时值为UserId
        /// </summary>
        public long OnlineId { get; set; }
        /// <summary>
        /// jwt编号
        /// </summary>
        public long RefreshTokenId { get; set; }
        public long AccessTokenId { get; set; }
        public TokenTypeEnum TokenType { get; set; }
        public string TokenTypeName { get; set; }
        public int CompanyCode { get; set; }
        public string CompanyName { get; set; }
        public long UserId { get; set; }
        public string WorkDayId { get; set; }
        public string UserCode { get; set; }
        public string UserName { get; set; }
        public List<long> RoleIds { get; set; }

        public string ConnectionId { get; set; }

        public string RequestIp { get; set; }

        public string IpAddress { get; set; }
        public string OperatingSystem { get; set; }
        public string DeviceType { get; set; }
        public string BrowserName { get; set; }
        public string Version { get; set; }

        public DateTime LoginTime { get; set; }

        public DateTime CreateTime { get; set; }

        public DateTime AccessExpiresTime { get; set; }

        public DateTime RefreshExpiresTime { get; set; }
    }

    public class OnlineUserQuery : PageModel
    {
        public string CreateByName { get; set; }
    }

    public class IsOnlineInfo
    {
        public bool IsOnline { get; set; }

        public string Message { get; set; }

        public OnlineUserModel CurrentUserInfo { get; set; }
    }


    public class LoginUserModel
    {
        public long RefreshTokenId { get; set; }
        public long AccessTokenId { get; set; }
        public TokenTypeEnum TokenType { get; set; }
        public int CompanyCode { get; set; }
        public long UserId { get; set; }
        public string WorkDayId { get; set; }
        public string UserCode { get; set; }
        public string UserName { get; set; }

        public DateTime LoginTime { get; set; }

        public List<long> RoleIds { get; set; }
    }
}
